﻿using Domain.Entity.Config;
using Domain.Repository.IConfig;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFCore.Repository.Config
{
    public class Config_public_charRepository : IConfig_public_charRepository
    {
        private readonly MyDbContext myDbContext;

        public Config_public_charRepository(MyDbContext myDbContext)
        {
            this.myDbContext = myDbContext;
        }
        //添加
        public async Task<int> AddEIAsync(Config_public_char config_Public_Char)
        {
            myDbContext.config_Public_Chars.Add(config_Public_Char);
            return await myDbContext.SaveChangesAsync();
        }
        //删除
        public async Task<int> DeleteEIAsync(int Id)
        {
            Config_public_char cpc = new Config_public_char()
            {
                Pbc_id = Id
            };
            myDbContext.config_Public_Chars.Remove(cpc);
            return await myDbContext.SaveChangesAsync();
        }
        //查询
        public async Task<List<Config_public_char>> GetCPCAstnc()
        {
            return await myDbContext.config_Public_Chars.ToListAsync();
        }

        public async Task<List<Config_public_char>> GetCPCAttributeKindAsync(string Attribute_kind)
        {
            return await myDbContext.config_Public_Chars.Where(c =>c.Attribute_kind == Attribute_kind).ToListAsync();
        }
    }
}
